home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 016 / flip.arc / FLIP.ASM next >
Encoding:
Assembly Source File  |  1986-10-28  |  6.1 KB  |  453 lines

  1. Title FLIP - prankware from NCR - GPSD
  2.  
  3. ; Flip will read the command line, looking for the number of minutes to
  4. ; delay, if none is found, Flip will ask you for the delay time.
  5.  
  6. ; after link, copy .exe to dummy, debug dummy, -m400 l8000 100, -w, -q
  7. ; copy dummy to .com and run .com   Any int 10 with ah=0 will reset
  8.  
  9.  
  10. abs0        segment at 0
  11.         org 4*8h
  12. timer_int    dw    2 dup (?)
  13.         org 4*10h
  14. video_int    dw    2 dup (?)
  15.         org 450h
  16. cursor_pos    dw    ?
  17.  
  18. abs0        ends
  19.  
  20. code        segment
  21.         org 100h
  22.         assume cs:code, ds:code
  23.         jmp    start
  24.  
  25. video_vector    dw    2 dup (?)
  26. timer_vector    dw    2 dup (?)
  27. save_screen    dw    25*80 dup (?)
  28. hour        dw    0
  29. min        dw    30
  30. prompt_message    db    'Enter the sleep time in minutes... $'
  31. input_buf    db    3,0,'     '
  32. immediate_flag    db    0
  33. timer_count    db    0ffh
  34. line        db    0
  35. pos        db    0
  36.  
  37.  
  38. start:        push    cs
  39.         pop    ds
  40.  
  41.         or    byte ptr es:[80h],00
  42.         jz    ask            
  43.  
  44.         mov    cl,es:[80h]
  45.         mov    ch,0
  46.         inc    cx
  47.         inc    cx
  48.         mov    di,offset input_buf+1
  49.         mov    si,80h
  50.         rep    movsb
  51.         jmp    get_time
  52.         
  53. ask:        mov    ah,9
  54.         mov    dx,offset prompt_message
  55.         int    21h
  56.         mov    ah,0ah
  57.         mov    dx,offset input_buf
  58.         int    21h
  59.  
  60. get_time:    mov    ah,2ch
  61.         int    21h
  62.         mov    al,ch
  63.         mov    ah,0
  64.         mov    hour,ax
  65.         mov    al,cl
  66.         mov    min,ax
  67.         mov    ax,0
  68.         mov    si,offset input_buf+2
  69.         mov    ch,0
  70.         mov    cl,input_buf+1
  71. get_offset:    mov    dl,[si]
  72.         inc    si
  73.  
  74.         cmp    dl,'0'
  75.         jb    offset_loop
  76.         cmp    dl,'9'
  77.         ja    offset_loop
  78.  
  79.         mov    bx,10
  80.         push    dx
  81.         mul    bx
  82.         pop    dx
  83.         sub    dl,30h
  84.         mov    dh,0
  85.         add    ax,dx
  86.  
  87. offset_loop:    loop    get_offset
  88.  
  89.         cmp    ax,0
  90.         jne    offset_done
  91.  
  92. got_offset:    mov    cs:immediate_flag,0ffh
  93.         jmp    all_done
  94.  
  95. offset_done:    add    min,ax
  96.  
  97. do_mod_60:    cmp    min,60
  98.         jb    all_done
  99.  
  100.         sub    min,60
  101.         inc    hour
  102.         jmp    do_mod_60
  103.  
  104. all_done:    sub    ax,ax
  105.         mov    es,ax
  106.         assume  es:abs0
  107.  
  108.         mov    ax,word ptr es:timer_int
  109.         mov    bx,word ptr es:timer_int+2
  110.         mov    cs:timer_vector, ax
  111.         mov    cs:timer_vector+2, bx
  112.         cli
  113.  
  114.         mov    word ptr es:timer_int, offset timer_handler
  115.         mov    word ptr es:timer_int+2, cs
  116.  
  117.         sti
  118.  
  119.         lea    dx,prog_end
  120.         int    27h
  121.         
  122. timer_handler    proc    far
  123.  
  124.         assume cs:code, ds:nothing, es:nothing
  125.  
  126.         cmp    immediate_flag,0
  127.         je    test_count
  128.  
  129.         mov    immediate_flag,0
  130.         push    ax
  131.         push    bx
  132.         push    cx
  133.         push    dx
  134.         push    si
  135.         push    di
  136.         push    bp
  137.         push    es
  138.         push    ds
  139.  
  140.  
  141.         jmp    flip_screen
  142.  
  143. test_count:    inc    timer_count
  144.         jz    timer_test
  145.  
  146.         jmp    dword ptr timer_vector
  147.  
  148. timer_test:    push    ax
  149.         push    bx
  150.         push    cx
  151.         push    dx
  152.         push    si
  153.         push    di
  154.         push    bp
  155.         push    es
  156.         push    ds
  157.  
  158.         sub    ax,ax
  159.         mov    es,ax
  160.  
  161.         mov    ax,es:[046eh]
  162.         cmp    ax,hour
  163.         jne    timer_test_2
  164.  
  165.         mov    ax,es:[046ch]
  166.         mov    bx,1092
  167.         mov    dx,0
  168.         div    bx
  169.         cmp    ax,min
  170.         je    flip_screen
  171.  
  172. timer_test_2:    pop    ds
  173.         pop    es
  174.         pop    bp
  175.         pop    di
  176.         pop    si
  177.         pop    dx
  178.         pop    cx
  179.         pop    bx
  180.         mov    al,20h
  181.         out    20h,al
  182.         pop    ax
  183.         iret
  184.  
  185. flip_screen:    cli
  186.  
  187.         sub    ax,ax
  188.         mov    es,ax
  189.  
  190.         mov    ax,cs:timer_vector
  191.         mov    bx,cs:timer_vector+2
  192.         mov    word ptr es:timer_int,ax
  193.         mov    word ptr es:timer_int+2,bx
  194.  
  195.         sti
  196.         mov    al,20h
  197.         out    20h,al
  198.  
  199.         mov    ax,0b800h
  200.         mov    ds,ax
  201.         mov    cx,25*80
  202.         mov    di,offset save_screen
  203.         mov    si,0
  204. mov_sw_loop2:    mov    ax,ds:[si]
  205.         mov    cs:[di],ax
  206.         inc    si
  207.         inc    si
  208.         inc    di
  209.         inc    di
  210.         loop    mov_sw_loop2
  211.  
  212.         mov    ax,es:cursor_pos
  213.         push    ax
  214.         
  215.         mov    ax,6
  216.         int    10h
  217.  
  218.         pop    ax
  219.         mov    es:cursor_pos,ax    
  220.  
  221.         mov    si,offset save_screen
  222.         mov    cx,25
  223.         mov    di,7759
  224.  
  225. line_loop:    push    si
  226.         push    cx
  227.         push    di
  228.         call    draw_line
  229.         pop    di
  230.         pop    cx
  231.         pop    si
  232.         sub    di,320
  233.         add    si,160
  234.         loop    line_loop
  235.  
  236.         mov    ax,0
  237.         mov    es,ax
  238.  
  239.         mov    ax,es:video_int
  240.         mov    bx,es:video_int+2
  241.         mov    video_vector,ax
  242.         mov    video_vector+2,bx
  243.  
  244.         mov    word ptr es:video_int, offset video_handler
  245.         mov    word ptr es:video_int+2, cs
  246.  
  247.         pop    ds
  248.         pop    es
  249.         pop    bp
  250.         pop    di
  251.         pop    si
  252.         pop    dx
  253.         pop    cx
  254.         pop    bx
  255.         pop    ax
  256.         iret
  257.  
  258. timer_handler    endp
  259.  
  260. draw_line:    mov    cx,80
  261. draw_line_loop:    mov    al,cs:[si]
  262.         inc    si
  263.         inc    si
  264.         push    di
  265.         push    si
  266.         push    cx
  267.         call    draw_char
  268.         pop    cx
  269.         pop    si
  270.         pop    di
  271.         dec    di
  272.  
  273.         loop    draw_line_loop
  274.         ret
  275.  
  276.  
  277. draw_char:    mov    ah,0
  278.         shl    ax,1
  279.         shl    ax,1
  280.         shl    ax,1
  281.         mov    si,ax
  282.         mov    ax,0f000h
  283.         mov    es,ax
  284.         add    si,0fa6eh
  285.         mov    ax,0b800h
  286.         mov    ds,ax
  287.  
  288.         mov    al,es:[si+7]
  289.         call    rotate
  290.         mov    ds:[di],al
  291.  
  292.         mov    al,es:[si+6]
  293.         call    rotate
  294.         mov    ds:[di+2000h],al
  295.  
  296.         add    di,80
  297.  
  298.         mov    al,es:[si+5]
  299.         call    rotate
  300.         mov    ds:[di],al
  301.  
  302.         mov    al,es:[si+4]
  303.         call    rotate
  304.         mov    ds:[di+2000h],al
  305.  
  306.         add    di,80
  307.  
  308.         mov    al,es:[si+3]
  309.         call    rotate
  310.         mov    ds:[di],al
  311.  
  312.         mov    al,es:[si+2]
  313.         call    rotate
  314.         mov    ds:[di+2000h],al
  315.  
  316.         add    di,80
  317.  
  318.         mov    al,es:[si+1]
  319.         call    rotate
  320.         mov    ds:[di],al
  321.  
  322.         mov    al,es:[si]
  323.         call    rotate
  324.         mov    ds:[di+2000h],al
  325.  
  326.         ret
  327.  
  328. rotate:        mov    ah,0
  329.  
  330.         shl    al,1
  331.         rcr    ah,1
  332.  
  333.         shl    al,1
  334.         rcr    ah,1
  335.  
  336.         shl    al,1
  337.         rcr    ah,1
  338.  
  339.         shl    al,1
  340.         rcr    ah,1
  341.  
  342.         shl    al,1
  343.         rcr    ah,1
  344.  
  345.         shl    al,1
  346.         rcr    ah,1
  347.  
  348.         shl    al,1
  349.         rcr    ah,1
  350.  
  351.         shl    al,1
  352.         rcr    ah,1
  353.  
  354.         mov    al,ah
  355.         ret
  356.  
  357. video_handler    proc    far
  358.  
  359.         cmp    ah,0
  360.         jne    video_2
  361.  
  362.         push    ax
  363.         push    bx
  364.         push    es
  365.         mov    ax,0
  366.         mov    es,ax
  367.         mov    ax,video_vector
  368.         mov    bx,video_vector+2
  369.         mov    word ptr es:video_int,ax
  370.         mov    word ptr es:video_int+2,bx
  371.  
  372.         pop    es
  373.         pop    bx
  374.         pop    ax
  375.         mov    al,2
  376.         jmp    dword ptr video_vector
  377.  
  378. video_2:    cmp    ah,2
  379.         jne    video_3
  380.  
  381.         jmp    dword ptr video_vector
  382.         iret
  383.  
  384. video_3:    cmp    ah,3
  385.         jne    video_4
  386.  
  387.         jmp    dword ptr video_vector
  388.         iret
  389.  
  390. video_4:    cmp    ah,9
  391.         jne    video_5
  392.  
  393.         jmp    write_char_attr
  394.  
  395. video_5:    cmp    ah,10
  396.         jne    video_6
  397.  
  398.         jmp    write_char_attr
  399.  
  400. video_6:    cmp    ah,6
  401.         jne    video_7
  402.  
  403.         mov    ah,7
  404.         jmp    video_99
  405.  
  406. video_7:    cmp    ah,7
  407.         jne    video_8
  408.  
  409.         mov    ah,6
  410.         jmp    video_99
  411.  
  412. video_8:
  413. video_99:    jmp    dword ptr video_vector
  414.  
  415. video_handler    endp
  416.         
  417. write_char_attr:
  418.         push    ds
  419.         push    es
  420.         push    bx
  421.         push    cx
  422.         push    dx
  423.  
  424.         push    ax
  425.  
  426.         mov    ax,0
  427.         mov    es,ax
  428.         mov    al,24
  429.         sub    al,byte ptr es:cursor_pos+1
  430.         mov    ah,0
  431.         mov    bx,320
  432.         mul    bx
  433.         mov    bl,79
  434.         sub    bl,byte ptr es:cursor_pos
  435.         mov    bh,0
  436.         add    ax,bx
  437.         mov    di,ax
  438.  
  439.         pop    ax
  440.         call    draw_char
  441.  
  442.         pop    dx
  443.         pop    cx
  444.         pop    bx
  445.         pop    es
  446.         pop    ds
  447.         iret
  448.  
  449.  
  450. prog_end    label    byte
  451. code        ends
  452.         end
  453.